<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .div1 {
      width: 100px;
      height: 100px;
      background-color: royalblue;
    }
    .active {
      color: red;
    }
    .lazy {
      color: green;
    }
    .div3 {
      font-size: 16px;
    }
  </style>
</head>
<body>
  <div id="app">
    <p>动态样式：class和style</p>
    <!-- 字符串拼接和变量替换 -->
    <div :class="classname+1"></div>
    <!-- 符合条件时才有对应的class -->
    <div :class="{active: isActive}">我是一段文字</div>
    <!-- 符合条件时有一个class，不符合条件有另一个class -->
    <div v-bind:class="isActive?'active':'lazy'">我是一段文字</div>
    <!-- 各种情况都有 -->
    <div :class="['div1', isActive?'active':'lazy', classname2+'3', {active: isActive}]">我是一段文字</div>
    <hr>
    <!-- 字符串拼接和变量替换 -->
    <p :style="{color: color1, fontSize: size+'px'}">我是一段文字</p>
    <p :style="freeStyle">我是一段文字</p>
    <p :style="[style1, style2]">我是一段文字</p>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        classname: 'div',
        isActive: false,
        classname2: 'div',
        color1: 'red',
        size: '30',
        freeStyle: {
          color: 'blue',
          fontWeight: 900
        },
        style1: {
          color: 'pink'
        },
        style2: {
          fontStyle: 'italic'
        }
      }
    })
  </script>
</body>
</html>